#-------------------------------------------------------------------------------
# Name:        VideoTools
# Purpose:
#
# Author:      Pablo
#
# Created:     09/03/2012
# Copyright:   (c) Monxcleyr Productions 2012
# Licence:     GPL v3
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import pygame

class Resize():
  """
Resize window
  """

  def __init__(self, initsize):

    # Smallest width the window can have
    self.smallest = 40
    self.initsize = initsize

  def scale(self, scale, size):

    """ scale(scale factor, event.size)

        returns size(width, height)"""

    # Keep window to scale when resized.
    width = size[0]
    height = int(width / scale)

    # Don't let the window get too small.
    if width < self.smallest:
      width = self.smallest
      height = int(width / scale)


    return (width, height)


class Mouse():

  def __init__(self, initsize):
    self.initsize = initsize

  def scale(self, mouse, size):

    # find the scale of the unscaled surface to the scaled one.
    surfscale = float(self.initsize[0]) / float(size[0])

    # scale the mouse :D
    if surfscale >= 1:
      newmouse = (float(mouse[0]*surfscale), float(mouse[1]*surfscale))
    elif surfscale < 1:
      newmouse = (float(mouse[0]*surfscale), float(mouse[1]*surfscale))

    return newmouse
